#!/usr/bin/env python

import sys
from itertools import groupby
from collections import defaultdict

def main():
    grp_gen = (line.strip().split('\t') for line in sys.stdin)
    for path_id, grp in groupby(grp_gen, key=lambda i:i[0]):
        grp = list(grp)
        genom_dict = defaultdict(int)
        for p, genom_ids_str in grp:
            for genom_id in map(int, genom_ids_str.split(',')):
                genom_dict[genom_id] += 1
        length = len(grp)
        avg_vector = sorted((i, float(cnt)/length) for (i, cnt) in genom_dict.iteritems())
        print "%s\t%s" % (path_id, ','.join("%s:%.5f"%item for item in avg_vector))


if __name__ == '__main__':
    import gc
    gc.disable()
    
    main()

